using System;

namespace Catastrophe.AutoSulution.TaskM
{
	public interface IScheduleControl
	{
		TaskComplete TaskCompleteNow { get; }

		/// <summary>
		/// 当前任务详情
		/// </summary>
		ScheduleMethodInfo ScheduleMethodInfoNow { get; }

		/// <summary>
		/// 超时的默认设定值
		/// </summary>
		long TimeOutDefault { get; set; }

		/// <summary>
		///     等待执行完成循环周期时间
		/// </summary>
		int WaitCompleteInerval { get; set; }

		/// <summary>
		///     执行方法间隔
		/// </summary>
		int ExcuteInterval { get; set; }

		/// <summary>
		///     是否检测等待超时
		/// </summary>
		bool CheckWaitTimeOut { get; set; }

		/// <summary>
		/// 剩余超时时间
		/// </summary>
		long RemainTimeOut { get; }

		/// <summary>
		/// 是否阻塞/暂停状态
		/// </summary>
		bool IsBlock { get; }

		/// <summary>
		/// 最大步骤-进度最大值
		/// </summary>
		int MaxStep { get; }

		/// <summary>
		/// 是否启动
		/// </summary>
		bool IsStarted { get; }

		/// <summary>
		/// 是否任务结束
		/// </summary>
		bool IsFinished { get; }

		/// <summary>
		/// 名称
		/// </summary>
		string Name { get; }

		/// <summary>
		/// 调度对象
		/// </summary>
		object Instance { get; }

		/// <summary>
		/// 执行完成并释放
		/// </summary>
		Action DisposedHandler { get; set; }

		/// <summary>
		/// 暂停
		/// </summary>
		Action StopHandler { get; set; }

		/// <summary>
		///     控制流程提示(每次执行方法的时候触发)
		/// </summary>
		Action<TaskComplete> ControlStepHandler { get; set; }

		/// <summary>
		///     异步启动
		/// </summary>
		void Start();

		/// <summary>
		///    释放-取消运行标识，不会立即完成，完成以后回调DisposedHandler
		/// </summary>
		void Dispose();

		/// <summary>
		///     手动释放-取消运行标识并等待线程结束
		/// </summary>
		void DisposeWait();

		/// <summary>
		///     暂停-执行一个完整周期以后
		/// </summary>
		void Stop();

		/// <summary>
		///     继续执行
		/// </summary>
		void Continue();

		/// <summary>
		/// 获取方法的描述信息
		/// </summary>
		/// <param name="funcMethod"></param>
		/// <returns></returns>
		ScheduleAttribute GetMethodDescribe(Func<TaskComplete, TaskComplete> funcMethod);

		/// <summary>
		/// 获取步骤的索引值
		/// </summary>
		/// <param name="funcMethod"></param>
		/// <returns></returns>
		int StepIndexNow(Func<TaskComplete, TaskComplete> funcMethod);

		int StepIndexNow(string methodName);

		/// <summary>
		/// 清空超时时间
		/// </summary>
		void ClearTimeOut();
	}
}
